package config

import "github.com/spf13/viper"

type Mysql struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
}
type Redis struct {
	Host     string
	Port     int
	Password string
	Database int
}
type Config struct {
	Mysql
	Redis
}

var AppConfig Config

func Init() (*Config, error) {
	viper.SetConfigFile("config/config.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		return nil, err
	}
	err = viper.Unmarshal(&AppConfig)
	if err != nil {
		return nil, err
	}
	return &AppConfig, nil
}
